package com.util.description;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yutianhong
 * @version 1.0
 * @since 2024/01/01 23:16
 */
public interface TypeVariableTypeDesc extends TypeDesc {

    static TypeVariableTypeDesc of(String className, List<TypeDesc> upperBounds) {
        return new DefaultTypeVariableTypeDesc(className, upperBounds);
    }

    @Override
    default boolean isTypeVariable() {
        return true;
    }

    List<TypeDesc> getUpperBounds();
}

class DefaultTypeVariableTypeDesc implements TypeVariableTypeDesc {
    String className;
    List<TypeDesc> upperBounds;

    public DefaultTypeVariableTypeDesc(String className, List<TypeDesc> upperBounds) {
        this.className = className;
        this.upperBounds = new ArrayList<>(upperBounds);
    }

    @Override
    public String className() {
        return className;
    }

    @Override
    public List<TypeDesc> getUpperBounds() {
        return upperBounds;
    }
}
